package com.deer.wms.instock.web;

import com.deer.wms.ASN.manage.model.asn.AsnMaster;
import com.deer.wms.instock.model.disptch.DispatCriteria;
import com.deer.wms.instock.service.TransferBillService;
import com.deer.wms.project.root.core.result.Result;
import com.deer.wms.project.root.core.result.ResultGenerator;
import com.deer.wms.ware.task.model.SO.SoDetail;
import com.deer.wms.ware.task.model.SO.vo.SoDetailVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: xu
 * @Date: 2022/06/21/15:46
 * @Description: 齐套性检查
 */
@Api(description = "齐套性检查")
@RestController
@RequestMapping("/dispatch")
public class DispatchController {

    @Autowired
    private TransferBillService transferBillService;

    @ApiOperation(value = "分页列表")
    @GetMapping("/list")
    public Result list(DispatCriteria criteria) {
        PageHelper.startPage(criteria.getPageNum(), criteria.getPageSize());
        List<AsnMaster> list = transferBillService.alignList(criteria);
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.genSuccessResult(pageInfo);
    }

    @ApiModelProperty("根据任务单号查询")
    @GetMapping("/detail")
    public Result detail(String billNo) {
        SoDetailVo soDetailVo =   transferBillService.detail(billNo);
        return ResultGenerator.genSuccessResult(soDetailVo);
    }
    @ApiModelProperty("根据任务单号查询")
    @GetMapping("/beBeing")
    public Result beBeing(String itemCode,String billNo) {
      List<SoDetail> soDetails =  transferBillService.beBeing(itemCode, billNo);

        return ResultGenerator.genSuccessResult(soDetails);
    }

    @PostMapping("/dispatch")
    @ApiModelProperty("齐套提交")
    private Result dispatch(@RequestBody SoDetailVo soDetailVo) {
        return ResultGenerator.genSuccessResult();
    }
}
